import logging

from config import BASE_HOST


class ChargeApi(object):

    def __init__(self,sess):
        self.ses=sess
    #获取充值验证码接口
    def get_charge_code(self,r):
        cha_url=BASE_HOST+"/common/public/verifycode/123400"
        cha_res=self.ses.get(url=cha_url)
        logging.info(f"获取充值验证码结果是{cha_res}")
        return cha_res

    def charge_money(self,amount):
        charge_data={"paymentType": "chinapnrTrust", "amount": amount,"formStr": "reForm",  "valicode": "8888"}
        charge_url=BASE_HOST+"/trust/trust/recharge"
        cha_mon_res=self.ses.post(url=charge_url,data=charge_data)
        logging.info(f"充值结果是{cha_mon_res}")
        return cha_mon_res

    def third_charge(self,url,thi_data):
        third_res=self.ses.post(url=url,data=thi_data)
        logging.info(f"第三方充值结果是{third_res}")
        return third_res


